package com.jinyu.jyly.adapter;

import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.king.image.imageviewer.ImageViewer;
import com.king.image.imageviewer.loader.GlideImageLoader;
import com.jinyu.jyly.R;
import com.jinyu.jyly.bean.MineBuyOrderInfo;

import java.util.List;


/**
 *
 */
public class MinePageSellTabAdapter extends BaseQuickAdapter<MineBuyOrderInfo.DataBean, BaseViewHolder> {

    private Activity activity;
    public MinePageSellTabAdapter(List<MineBuyOrderInfo.DataBean> data, int layoutResIds, Activity activity) {
        super(layoutResIds, data);
        this.activity = activity;
    }


    @Override
    protected void convert(final BaseViewHolder helper, final MineBuyOrderInfo.DataBean item) {
        helper.addOnClickListener(R.id.tv_bottom_shoukuan);
        helper.setText(R.id.tv_order_num, item.getOrder_num());
        helper.setText(R.id.tv_order_s, item.getName());
        helper.setText(R.id.tv_order_time, item.getCreate_time());
        helper.setText(R.id.tv_kuhao, item.getStock_num());
        helper.setText(R.id.tv_buy_price, "￥"+item.getPrice());
        helper.setText(R.id.tv_zhuan_price, "￥"+item.getOld_price());
        helper.setText(R.id.tv_shifu, "￥"+item.getPrice());
        helper.setText(R.id.tv_buy_mobile, item.getBuy_mobile());
        ImageView iv_pay_img = helper.getView(R.id.iv_pay_img);

        RequestOptions options = new RequestOptions();
        options.error(R.mipmap.space_list);
        Glide.with(mContext).load(item.getPay_pic())
                .apply(options)
                .into((ImageView)helper.getView(R.id.iv_pay_img));

        iv_pay_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                ImageViewer.load(item.getPay_pic())//要加载的图片数据，单张或多张
                        .imageLoader(new GlideImageLoader())//加载器，imageLoader必须配置，目前内置的有GlideImageLoader或PicassoImageLoader，也可以自己实现
                        .start(activity, iv_pay_img);//activity or fragment, 跳转时的共享元素视图

            }
        });


        LinearLayout ll_bottom = helper.getView(R.id.ll_bottom);

        int status = item.getStatus();
        switch (status) {
            case 0:
                //待入场
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "待入场");
                break;
            case 1:
                //待被买
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "待被买");
                break;
            case 2:
                //已锁单
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "待付款");
                break;
            case 3:
                //已付款,需要点确认收款
                ll_bottom.setVisibility(View.VISIBLE);
                helper.setText(R.id.tv_order_state, "已付款");
                break;
            case 4:
                //已确认收款
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "已确认收款");
                break;
            case 5:
                //已完成
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "已完成");
                break;
            case 6:
                //已取消
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "已取消");
                break;
            case 7:
                //待发货
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "待发货");
                break;
            case 8:
                //待收货
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "待收货");
                break;
            case 9:
                //已收货
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "已收货");
                break;

        }

    }


}


